import { commentListPage } from "@/api/comment"
import { userListId } from "@/api/user"

const user = {
  state: {
    data:{},
    username:null
  },

  mutations: {
    CommentList:(state,data)=>{
      state.data=data;
    },
    UserListId:(state,data)=>{
      state.username=data;
    }
  },

  actions: {
    // 无页码约束的所有用户数据
    ListCommentType({commit},playload) {
      return new Promise((resolve, reject) => {
        commentListPage(playload).then(response => {
          // console.log(response);
          commit("CommentList",response);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取数据用户
    GetIdUser({commit},playload) {
      return new Promise((resolve, reject) => {
        userListId(playload).then(response => {
          console.log(response.username);
          commit("UserListId",response.username);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }

  }
}

export default user;
